import Vue from 'vue'
import axios from 'axios'
import App from './App.vue'
import router from './router'
// 图片预览
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import moment from 'moment'
// 导入全局样式表
import '@/assets/css/public.css'
import ElementUi from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import * as echarts from 'echarts'

Vue.use(ElementUi)
Vue.config.productionTip = false
Vue.use(Viewer)

moment.locale('zh-cn')
Vue.prototype.$moment = moment
Vue.prototype.$echarts = echarts
// 配置请求的根路径

Vue.prototype.$http = axios
// 1、添加请求拦截器，在请求头中加token
axios.interceptors.request.use(
  config => {
    if (localStorage.getItem('Authorization')) {
      config.headers.Authorization = localStorage.getItem('Authorization')
    }
    return config
  },
  error => {
    return Promise.reject(error)
  })
axios.defaults.headers.contentType = 'application/json;charset=UTF-8'
axios.defaults.baseURL = 'http://127.0.0.1:3007/'
Vue.prototype.$bus = new Vue()

// 全局过滤器
Vue.filter('DateFormat', function (timeVal) {
  return timeVal.split(' ')[0]
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
